<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <title>列表</title>
    <link href="__STATIC__/component/pear/css/pear.css" rel="stylesheet"/>
</head>
<body class="pear-container">

{php $tabs=widget('config_form')->get()}

<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-tab layui-tab-brief" lay-filter="component-tabs-hash">
            <ul class="layui-tab-title">
                {foreach $tabs as $k=>$vo}
                <li{if $k==0:} class="layui-this"{/if} lay-id="{$vo.id}">{$vo.title}</li>
                {/foreach}
                <li class="tab-add" lay-id="99999"><i class="layui-icon layui-icon-add-1"></i></li>
            </ul>
            <div class="layui-tab-content">
                {foreach $tabs as $k=>$vo}
                <div class="layui-tab-item{if $k==0:} layui-show{/if}">
                    <blockquote class="layui-elem-quote">{$vo.memo}</blockquote>
                    <form class="layui-form" action="{:url('save_config')}?group_id={$vo.id}">
                        {$vo.html}
                        <div class="layui-form-item">
                            <button type="button" class="layui-btn" lay-submit="" lay-filter="save">保存</button>
                            <button type="button" class="layui-btn layui-btn-primary" data-event="reload">重载</button>
                            {if $vo['sign']=='email':}
                            <button type="button" class="layui-btn layui-btn-normal" data-event="send">测试邮件</button>
                            {/if}
                        </div>
                    </form>
                </div>
                {/foreach}
                <div class="layui-tab-item">
                    <blockquote class="layui-elem-quote">添加自定义配置</blockquote>
                    <form class="layui-form" action="{:url('add')}">
                        <div class="layui-form-item">
                            <label class="layui-form-label layui-form-item-required">配置分组</label>
                            <div class="layui-input-inline w30-100">
                                {:form_select('group_id', widget('config_group')->get(), '')}
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 配置分组</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label layui-form-item-required">配置标题</label>
                            <div class="layui-input-inline w30-100">
                                <input type="text" name="field_title" lay-verify="required" value="" placeholder="标题(中文)" class="layui-input" />
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 配置标题</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label layui-form-item-required">配置键名</label>
                            <div class="layui-input-inline w30-100">
                                <input type="text" name="field_name" lay-verify="required" value="" placeholder="键名(英文)" class="layui-input" />
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 配置键名</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">配置键值</label>
                            <div class="layui-input-inline w30-100">
                                <textarea name="field_value" placeholder="配置值" class="layui-textarea"></textarea>
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 配置键值</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">配置说明</label>
                            <div class="layui-input-inline w30-100">
                                <input type="text" name="field_comment" value="" placeholder="默认：配置标题" class="layui-input" />
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 配置说明</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">表单类型</label>
                            <div class="layui-input-inline w30-100">
                                {:form_select('form_type', config_get('cms.form_type', 'text=文本框', true), 'text')}
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 表单类型</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">输入提示</label>
                            <div class="layui-input-inline w30-100">
                                <input type="text" name="form_tips" value="" placeholder="placeholder属性 默认：配置标题" class="layui-input" />
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 开关：开启|关闭</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">前端验证</label>
                            <div class="layui-input-inline w30-100">
                                {:form_select('lay_verify', config_get('cms.lay_verify', 'none=无'), 'none')}
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i>layui的lay-verify属性</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">表单属性</label>
                            <div class="layui-input-inline w30-100">
                                <textarea name="form_attr" id="editor-form_attr" placeholder="属性名=属性值|属性名=属性值(如有=和|符号可用[eq]和[or]代替)" class="layui-textarea"></textarea>
                            </div>
                            <div class="layui-form-mid" style="padding: 0!important;">
                                日期区间：class=layui-input datetime|data-date-range=-|data-date-type=date<br>
                                省市地区：data-toggle=city-picker <br>
                                下拉多选：xm-select=[键名]|xm-select-skin=normal<br>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">选项设置</label>
                            <div class="layui-input-inline w30-100">
                                <textarea name="form_options" id="editor-form_options" placeholder="选项值=选项名|选项值=选项名" class="layui-textarea"></textarea>
                            </div>
                            <div class="layui-form-mid">
                                select和radio的选项<br>
                                如有=和|符号可用[eq]和[or]代替
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">必填标记</label>
                            <div class="layui-input-inline w30-100">
                                <input type="hidden" name="form_required" value="0" />
                                <input type="checkbox" name="form_required" value="1" checked="checked" lay-skin="switch" lay-text="是|否" />
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 标题前的星号是否显示</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">容器样式</label>
                            <div class="layui-input-inline w30-100">
                                <input type="text" name="input_style" value="layui-input-inline w40-100" placeholder="默认：layui-input-block" class="layui-input" />
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> layui-input-group</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">禁删</label>
                            <div class="layui-input-inline w30-100">
                                <input type="hidden" name="is_sys" value="0">
                                <input type="checkbox" name="is_sys" value="1" lay-skin="switch" lay-text="是|否">
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 禁删防止误删</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">排序</label>
                            <div class="layui-input-inline w30-100">
                                <input type="number" name="sort" value="100" placeholder="请输入排序值" class="layui-input" min="0" step="10" lay-affix="number" />
                            </div>
                            <div class="layui-form-mid"><i class="layui-icon layui-icon-about layui-font-blue"></i> 越小排序越靠前</div>
                        </div>

                        <div class="layui-form-item">
                            <button class="layui-btn" lay-submit="" lay-filter="save">添加</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </form>
                </div>

            </div>
        </div>
    </div>
</div>


<script src="__STATIC__/component/layui/layui.js"></script>
<script src="__STATIC__/component/pear/pear.js"></script>
<script>
    layui.use(['aphp', 'form', 'aphpForm', 'layer'], function () {
        var aphp = layui.aphp;
        var form = layui.form;
        var aphpForm = layui.aphpForm;
        var $ = layui.$;

        aphpForm.bindEvent($("form.layui-form"));

        form.on('submit(save)', function (data) {
            aphp.request.postForm(data, 1);
            return false;
        });

        $(document).on('click', "[data-event='reload']", function () {
            parent.layui.admin.refreshThis();
        });

        $(document).on('click', "[data-event='send']", function () {
            aphp.request.getConfirm("{:url('api_test_send')}", '修改配置后需保存，确认要发送测试邮件吗？');
        });

        $(document).on('click', "[data-event='del']", function () {
            var id = $(this).data('id');
            aphp.request.getConfirm("{:url('del')}?id="+id, '确认要删除配置吗？', 1);
        });

    });
</script>
</body>
</html>